package com.quwancode.mavenmybatis.controller;

import com.quwancode.mavenmybatis.mapper.StudentMapper;
import com.quwancode.mavenmybatis.model.Student;
import com.quwancode.mavenmybatis.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @description:
 * @author: ChengKai
 * @time: 2023/3/3 8:58
 */
public class StudentController {

    //查
    public static void search() {
        // 第一步: 获得sqlSession对象
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        // 执行 这个过程就相当于创建一个interface的对象
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        List<Student> userList = studentMapper.selectStudentList();
        userList.forEach(System.out::println);
        sqlSession.close();
    }

}
